from django.db import models

# Create your models here.

class Forum(models.Model):
    title       = models.TextField()
    description = models.TextField()
    importance  = models.IntegerField()
 
    def __unicode__(self):
        return  self.title

class Topic(models.Model):
    forumId    = models.ForeignKey(Forum)
    startTime  = models.DateTimeField(auto_now_add = True)
    uname      = models.CharField(max_length=50)
    #uname      = models.CharField()
    title      = models.TextField()
    text       = models.TextField()

    def __unicode__(self):
        return '%s posted by %s at %s' % (self.title, self.uname, self.startTime)
 
class Post(models.Model):
    topicId   =	models.ForeignKey(Topic)
    uname     = models.CharField(max_length=50)
    postTime  = models.DateTimeField(auto_now_add = True)
    title     = models.TextField()
    text      = models.TextField()

# tags and documents referred by topics

class Tag(models.Model):
    topicId  = models.ForeignKey(Topic)
    tagLevel = models.IntegerField()
    tagName  = models.CharField(max_length=50)

class Cites(models.Model):
    topicId = models.ForeignKey(Topic)
    tid     = models.IntegerField()

